package com.gs.SynPatrolRep.model;


import com.gs.SynPatrolRep.callback.Callback;
import com.gs.SynPatrolRep.model.listener.OnResultListener;
import com.gs.SynPatrolRep.util.OKHttpUtil;

import java.lang.reflect.Type;

public class LoginModel {
    public void login(String json, final OnResultListener onResultListener, Type typeOfT) {
        OKHttpUtil.getInstance().postAsync(OKHttpUtil.NET_URL + "/api/users/login", json, new Callback() {
            @Override
            public void onSuccess(Object obj) {
                onResultListener.onSuccess(obj);
            }

            @Override
            public void onFailed(Exception e) {
                onResultListener.onFails(e);
            }
        }, typeOfT);
    }

    public void forgotPw(String email, final OnResultListener listener, Type typeofT) {
        OKHttpUtil.getInstance().getAsync(OKHttpUtil.NET_URL + "/api/users/forgotPwd?eMail=" + email,
                new Callback() {
                    @Override
                    public void onSuccess(Object obj) {
                        listener.onSuccess(obj);
                    }

                    @Override
                    public void onFailed(Exception e) {
                        listener.onFails(e);
                    }
                }, typeofT);
    }
}
